package net.aiion.weave.impl.startup;

import net.aiion.weave.spi.naming.ConversationContext;
import net.aiion.weave.spi.naming.SessionContext;
import net.aiion.weave.spi.startup.ConversationContextStartup;
import net.aiion.weave.spi.startup.SessionContextStartup;

public class SessionContextStartupImpl implements SessionContextStartup
{
    private final SessionContext sessionContext;

    public SessionContextStartupImpl(final SessionContext aSessionContext) {
        sessionContext = aSessionContext;
    }

    @Override
    public String getSessionContextId() {
        return sessionContext.getId();
    }

    @Override
    public ConversationContextStartup usingConversationContext(final String aConversationContextId) {
        return new ConversationContextStartupImpl(lookupConversationContext(aConversationContextId));
    }

    private ConversationContext lookupConversationContext(final String aConversationContextId) {
        return sessionContext.lookupConversationContext(aConversationContextId);
    }

    @Override
    public void executeShutdown() {
        sessionContext.dispose();
    }
}
